/*
 * logica.cpp
 *
 *  Created on: 08/12/2008
 *      Author: desadoc
 */

#include "logica.h"

void logica::salvar(const char* filename, QList<query*> toSave){

	int i;

	QFile myFile(filename);
	myFile.open( QIODevice::WriteOnly);

	QTextStream out(&myFile);

	for(i=0; i<toSave.size(); i++){
		out << toSave.at(i)->getQuestion();
		out << "\n";
	}

	out.flush();
}

void logica::abrir(const char* filename, QList<query*>& toSave){

	int i, num;
	query *q;
	QString s, file(filename);

	QFile myFile(filename);
	myFile.open(QIODevice::ReadOnly);

	QTextStream in(&myFile);

	num=0;

	while(!in.atEnd()){
		num++;
		s = in.readLine();

		q = new query(num);
		q->setQuestion(s);

		toSave.append(q);
	}

	//in.flush();
}

